package com.dongjiantong.quarantine.serviceImpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongjiantong.mybatis.ServiceMybatis;
import com.dongjiantong.quarantine.mapper.SupervisionRecordsMapper;
import com.dongjiantong.quarantine.model.SupervisionRecords;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by mz on 25/12/17.
 *
 */
@Slf4j
@Service(version = "1.0.0")
public class SupervisionRecordsReadServiceImpl extends ServiceMybatis<SupervisionRecords> implements SupervisionRecordsReadService{

    @Resource
    private SupervisionRecordsMapper supervisionRecordsMapper;


    /**
     * 查询单据详情
     *
     * @param id 单据id
     * @return SupervisionRecords
     */
    @Override
    public SupervisionRecords findById(Long id) {
        return supervisionRecordsMapper.selectByPrimaryKey(id);
    }


    /**
     * 获取但钱单据状态
     *
     * @param id 单据主键id
     * @return Integer status
     */
    @Override
    public Integer findStatusById(Long id) {
        return supervisionRecordsMapper.findStatusById(id);
    }

    /**
     * 养殖端的分页查询
     *
     * @param pageNum  页码
     * @param pageSize 条数
     * @param map      参数
     * @return PageInfo<SupervisionRecords>
     */
    @Override
    public PageInfo<SupervisionRecords> pagingForFarm(Integer pageNum, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNum, pageSize);

        List<SupervisionRecords> supervisionRecordsList = supervisionRecordsMapper.selectListForFarm(map);

        PageInfo<SupervisionRecords> supervisionRecordsPageInfo = new PageInfo<SupervisionRecords>(supervisionRecordsList);
        return supervisionRecordsPageInfo;
    }

    /**
     * 政府端的分页查询
     *
     * @param pageNum  页码
     * @param pageSize 条数
     * @param map      参数
     * @return PageInfo<SupervisionRecords>
     */
    @Override
    public PageInfo<SupervisionRecords> pagingForGovList(Integer pageNum, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNum, pageSize);

        List<SupervisionRecords> supervisionRecordsList = supervisionRecordsMapper.selectListForGovList(map);

        PageInfo<SupervisionRecords> supervisionRecordsPageInfo = new PageInfo<SupervisionRecords>(supervisionRecordsList);

        return supervisionRecordsPageInfo;
    }

    /**
     * 政府端的地图显示
     *
     * @param map 参数
     * @return List<SupervisionRecords>
     */
    @Override
    public List<SupervisionRecords> findListForGovMap(Map<String, Object> map) {
        return supervisionRecordsMapper.findListForGovMap(map);
    }

    /**
     * 政府端的地图显示
     *
     * @param map 参数
     * @return List<SupervisionRecords>
     */
    @Override
    public List<SupervisionRecords> findListForGovMapByFarmId(Map<String, Object> map) {
        return supervisionRecordsMapper.findListForGovMapByFarmId(map);
    }

    /**
     * 政府端轨迹list的分页查询
     *
     * @param pageNum  页码
     * @param pageSize 条数
     * @param map      参数
     * @return PageInfo<SupervisionRecords>
     */
    @Override
    public PageInfo<SupervisionRecords> pagingForGovTrace(Integer pageNum, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNum, pageSize);

        List<SupervisionRecords> supervisionRecordsList = supervisionRecordsMapper.selectForGovTrace(map);

        PageInfo<SupervisionRecords> supervisionRecordsPageInfo = new PageInfo<SupervisionRecords>(supervisionRecordsList);
        return supervisionRecordsPageInfo;
    }

    @Override
    public List<Map<String, Object>> findUser(Map<String, Object> map) {
        return supervisionRecordsMapper.findUser(map);
    }
}
